#pragma once

#include <Blobz.h>
#include <BlobzGui.h>
#include <BlobzUtility.h>
#include "Graphics/Video/Video.h"

namespace DigitalSignage
{
	// A basic video player class. Loads the video and provides playback controls
	class TutVideo1 : public Blobz::Interactable, public Blobz::GUIListener
	{
	public:
		TutVideo1();
		~TutVideo1();

	public:
		bool load(const QString& inApplicationDirectory, const QString& inFilePath);
		void unload();

		void onUpdate(float inFrameTime);

		void resetVideo();
		void onRender();

		void onFingerDown(const TouchListener::TouchData& inData);
		void onFingerUp(const TouchListener::TouchData& inData);
		void onFingerUpdate(const TouchListener::TouchData& inData);
		void onGUIEvent(Blobz::GUIBase* inpComponent, Blobz::GUIEvent inGUIEvent, Blobz::FingerEvent inFingerEvent);

	private:
		void loadGUI(const QString& inAppDir);
		void repositionGUI();
		QVector2D rotatePointAboutPoint(QVector2D inPointA, QVector2D inPointB, float inAngle );
		bool isInside(QVector2D inPoint);

		void pauseVideo();
		void playVideo();

	private:
		Blobz::Video mVideo1;
		Blobz::IDList mTouchList;		
		QString mApplicationDirectory;
		bool mIsLoaded;
		bool mLooping;
		bool mPaused;

		Blobz::GUIManager mGUIManager;
		Blobz::Button* mpBigPlay;
		Blobz::CheckBox* mpPlayPause;
		Blobz::Slider* mpTimeSlider;
		Blobz::CheckBox* mpLoop;
		Blobz::Button* mpVolume;
		Blobz::Slider* mpVolumeSlider;
	};
}
